﻿// JScript 文件

/*
系统参数关联数组
*/
var SysRelArr = new Array();

/*

用途：弹出窗口，父窗口不可操作

输入：url，弹出窗口连接

返回：无 

*/
function ShowModalDialog(url)
{
    window.showModalDialog(url);
}
/*

用途：详情界面弹出详情信息

输入：url，弹出窗口连接

返回：无 

*/
function ShowWarnDialog(url) {
    window.showModalDialog(url, "Warn", "dialogHeight:200px; dialogWidth:100px;resizable=yes,status=no;help=no;scrollbars=no;location=no"); // toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no,help = no, status=no, toolbar=no
}

/*

用途：详情界面弹出详情信息

输入：url，弹出窗口连接

返回：无 

*/
function ShowDetailsDialog(url)
{
    window.showModalDialog(url,"details","dialogHeight:600px; dialogWidth:550px;");// toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no,help = no, status=no, toolbar=no
}



/*

用途：详情界面弹出详情信息

输入：url，弹出窗口连接

返回：无 

*/
function ShowPicInfo(url)
{
    window.showModalDialog(url,"details","dialogHeight:550px; dialogWidth:550px;");// toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no,help = no, status=no, toolbar=no
}

/*

用途：弹出窗口，父窗口可操作

输入：url，弹出窗口连接

返回：无 

*/
function ShowModelessDialog(url)
{
    window.showModelessDialog(url);
}


/*

用途：关闭窗体

输入：无

返回：无 

*/
function Close()
{
    window.close();
}


/*

用途：检查输入对象的值是否符合整数格式

输入：str 输入的字符串

返回：如果通过验证返回true,否则返回false

 

*/

function isInteger( str ){ 
var regu = /^[-]{0,1}[0-9]{1,}$/;

return regu.test(str);
}

/*

用途：检查输入字符串是否是带小数的数字格式,可以是负数

输入：

s：字符串

返回：

如果通过验证返回true,否则返回false

 

*/

function isDecimal( str ){  

if(isInteger(str)) return true;

var re = /^[-]{0,1}(\d+)[\.]+(\d+)$/;

if (re.test(str)) {

if(RegExp.$1==0&&RegExp.$2==0) return false;

return true;

} else {

return false;

}

}


function CheckInt(obj)
{
    if (obj.readOnly)
    {
        return;
    }
    if (obj.value.length<=0)
    {
        return;
    }
    if (!isInteger(obj.value))
    {
        alert("请输入数字！");
        obj.value="";
        obj.select();
        obj.focus();
    }
}


function CheckFloat(obj)
{
    if (obj.readOnly)
    {
        return;
    }
    if (obj.value.length<=0)
    {
        return;
    }
    if (!isDecimal(obj.value))
    {
        alert("请输入小数！");
        obj.value="";
        obj.select();
        obj.focus();
    }
}




//修改时，所有控件读取属性是否可读转化函数 aiks 20090829
 function ChangeReadOnly(obj)
 {
    document.getElementById("btnSubmit").disabled = false;
    Controls = document.getElementsByTagName("input");
    for(var i =0;i<Controls.length;i++)//
    {
        if(Controls[i].name.indexOf("Cls") != -1)
        {
            Controls[i].readOnly = !Controls[i].readOnly;  
        }
    }
 }


 
/*
动态加载系统参数下拉选项
*/
 function SysDynamicOptions(sltObj)
 {
    var thisid = sltObj.getAttribute("id");
    var thisColumnName="";
	if(thisid.indexOf("-")!=-1)
	{
        thisColumnName = thisid.substring(thisid.indexOf("-")+1);
        thisColumnName = thisColumnName.substring(0,thisColumnName.lastIndexOf("-"));
	}else
	    thisColumnName = thisid.substring(3);
	    
    var relLength = SysRelArr.length;
    if(relLength == 0)
        return;
	
    //find the second's parentsysid
    var parentArr= new Array();
    parentArr.push(thisColumnName);
    var topColumn = thisColumnName;
    
    for(var i=0;i<relLength;i++)
    {
        if(topColumn == SysRelArr[i][0])
        {
            parentArr.push(SysRelArr[i][1]);
            topColumn = SysRelArr[i][1];
            i=-1;
        }
    }
    var secColumn="";
    for(var i=0;i<relLength;i++)
    { 
        if(thisColumnName == SysRelArr[i][1])
        {
            secColumn=SysRelArr[i][0];
            break;
        }
    }
    
    if(secColumn.length == 0)
        return;
        
    //get second select
    var secondid = "Cls-"+secColumn+"-10";
    var secondSlt= document.getElementById(secondid);
    if(secondSlt== null || typeof(secondSlt)=="undefined")
    {
        secondid = "Cls-"+secColumn+"-9";
        secondSlt= document.getElementById(secondid);
        if(secondSlt== null || typeof(secondSlt)=="undefined")
        {
            secondid = "Cls"+secColumn;
            secondSlt= document.getElementById(secondid);
        }
        if(secondSlt== null || typeof(secondSlt)=="undefined")
            return;
    }
    // clear second Select options
    secondSlt.options.length = 0; 
     
    //get SysTopArr
     eval("if(typeof(SysTopArr_"+topColumn+")!='undefined')var thisTopArr =SysTopArr_"+topColumn);
    if(thisTopArr == null || typeof(thisTopArr)=="undefined")
        return;

    //get SysArr    
     eval("if(typeof(SysArr_"+topColumn+")!='undefined')var thisSysArr =SysArr_"+topColumn);
    if(thisSysArr == null || typeof(thisSysArr)=="undefined")
        return;
    
     var topSltid = "Cls-"+topColumn+"-10";
    topSlt = document.getElementById(topSltid);
    if(topSlt== null || typeof(topSlt)=="undefined")
    {
        topSltid = "Cls"+topColumn;
        topSlt= document.getElementById(topSltid);
    }
    
    //get parent lever selected sysid
    var parentSysid="";
    for(var i=0;i<thisTopArr.length;i++)
    {
        if(thisTopArr[i][0]==topSlt.value)
        {
            parentSysid = thisTopArr[i][1];
            break;
        }
    }
    
    var tempPSysid = "";
    var icount = parentArr.length-1;
    if(icount<0)
        return;
    for(i=icount;i>-1;i--)
    {
        if(parentArr[i] == topColumn)
        {
            tempPSysid = parentSysid;
            continue;
        }
        var tpd = "Cls-"+parentArr[i]+"-10";
        var tpSlt= document.getElementById(tpd);
        if(tpSlt== null || typeof(tpSlt)=="undefined")
        {
            tpd = "Cls-"+parentArr[i]+"-9";
            tpSlt= document.getElementById(tpd);
            if(tpSlt== null || typeof(tpSlt)=="undefined")
            {
                tpd = "Cls"+parentArr[i];
                tpSlt= document.getElementById(tpd);
            }
            if(tpSlt== null || typeof(tpSlt)=="undefined")
                break;
        }
        var tpdvalue = tpSlt.value;
        if(tpdvalue.length==0)
        {
            ClearChildOptions(secondSlt);
            return;
        }
        for(var j=0;j<thisSysArr.length;j++)
        {
            if(thisSysArr[j][0]==tpdvalue && thisSysArr[j][3]==tempPSysid)
            {
                tempPSysid = thisSysArr[j][2];
                break;
            }
        }
    }
    var tmpOpt = document.createElement("option");
    tmpOpt.setAttribute("value","");
    tmpOpt.appendChild(document.createTextNode(""));
    secondSlt.appendChild(tmpOpt);
    
     for(var j=0;j<thisSysArr.length;j++)
     {
        if(thisSysArr[j][3]==tempPSysid)
        {
            tmpOpt = document.createElement("option");
            tmpOpt.setAttribute("value",thisSysArr[j][0]);
            tmpOpt.appendChild(document.createTextNode(thisSysArr[j][1]));
            secondSlt.appendChild(tmpOpt);
        }
     } 
     ClearChildOptions(secondSlt);
 }
 //清除子SELECT的选项
 function ClearChildOptions(parentSlt)
 {
    var thisid = parentSlt.getAttribute("id");
    var parentCol="";
	if(thisid.indexOf("-")!=-1)
	{
        parentCol = thisid.substring(thisid.indexOf("-")+1);
        parentCol = parentCol.substring(0,parentCol.lastIndexOf("-"));
	}else
	    parentCol = thisid.substring(3);
	    
    
    var relLength = SysRelArr.length;
    if(relLength == 0)
        return;
        
     var childArr= new Array();
    var topColumn = parentCol;
        
    for(var i=0;i<relLength;i++)
    {
        if(topColumn == SysRelArr[i][1])
        {
            childArr.push(SysRelArr[i][0]);
            topColumn = SysRelArr[i][0];
            i=-1;
        }
    }
    var icount = childArr.length;
    if(icount==0)
        return;
    for(var i=0;i<icount;i++)
    {
        var tpd = "Cls-"+childArr[i]+"-10";
        var tpSlt= document.getElementById(tpd);
        if(tpSlt== null || typeof(tpSlt)=="undefined")
        {
            tpd = "Cls-"+childArr[i]+"-9";
            tpSlt= document.getElementById(tpd);
            if(tpSlt== null || typeof(tpSlt)=="undefined")
            {
                tpd = "Cls"+childArr[i];
                tpSlt= document.getElementById(tpd);
            }
            if(tpSlt== null || typeof(tpSlt)=="undefined")
                break;
        }
        tpSlt.options.length = 0;
    } 
 }



ie4=(document.all)?true:false; 
ns4=(document.layers)?true:false; 
function toExit(){ 
var args=toExit.arguments; 
var visible=args[0]; 
if(ns4){ 
theObj=eval("document.layers[\'"+args[1]+"\']"); 
if(theObj)theObj.visibility=visible; 
} 
else if(ie4){ 
if(visible=='show')visible='visible'; 
if(visible=='hide')visible='hidden'; 
theObj=eval("document.all[\'"+args[1]+"\']"); 
if(theObj)theObj.style.visibility=visible; 
}

var adiv=document.getElementById("boysoft");
var bdiv=document.getElementById("csb");
var cdiv=document.getElementById("csb1");

if(adiv.style.visibility=="visible"){
   bdiv.style.display="none";
   cdiv.style.display="inline";
}else{
   bdiv.style.display="inline";
   cdiv.style.display="none";
}
var chk=myForm.c;
var p="";
for(var j=0;j<chk.length;j++){
   if(chk[j].checked){
    p+=chk[j].value+",";
   }
}
myForm.t1.value=p;
} 
function qk(){
myForm.t1.value="";
}

function checkAll()
{
if(myForm.c != undefined)
   {
    if(myForm.c.length == undefined)
    {
     if(myForm.c.checked == true)
      myForm.c.checked = false;
     else
      myForm.c.checked = true;
    }
    else
         { 
         for(var i=0;i<myForm.c.length;i++)
          {
              if(myForm.c[i].checked == true)
              myForm.c[i].checked = false;
              else
              myForm.c[i].checked = true; 
          }
          
      }
   }    
}




/*
     * 1——整型Integer，
     * 2——浮点型Float，
     * 3——字符型String，
     * 4——布尔Bool，
     * 5——Date，
     * 6——time， 
     * 7——Binary/Image
     
     My_Control_schoolinfoid_2
 */
 
    function getMyControlValue()
    {
        
        mycontrol = document.getElementsByTagName("input");
        $("Txt_mysql").value = "";
        $("Txt_temp").value = "";
        tstr = "";
        for(var i =0;i<mycontrol.length;i++)
        {   
            if(mycontrol[i].name.indexOf("My_Control_") != -1)//My_Control_
            {
                mycontrol[i].className = mycontrol[i].className.Trim();
                arr = mycontrol[i].name.split('_');
                if(arr[arr.length -1] == "1")
                {
                    if(mycontrol[i].className != "")
                    {
                        if(!isNumberOr_Comma( mycontrol[i].className ))
                        {
                            alert("请输入整数类型！");
                            mycontrol[i].select();
                            mycontrol[i].focus();
                            return;
                        }
                        tstr += arr[arr.length -2] + "=" + mycontrol[i].className + ";";
                    }
                }
                else if(arr[arr.length -1] == "2")
                {
                    if(mycontrol[i].className != "")
                    {
                        if(isLetter( mycontrol[i].className ))
                        {
                            alert("请输入浮点数类型！");
                            mycontrol[i].select();
                            mycontrol[i].focus();alert(mycontrol[i].className);
                            return;
                        }
                        tstr += arr[arr.length -2] + "=" + mycontrol[i].className + ";";
                       
                    }
                }
                else if(arr[arr.length -1] == "3")
                {
                    if(mycontrol[i].className != "")
                    {
                        tstr += arr[arr.length -2] + "=" + mycontrol[i].className + ";";
                    }
                }
                else if((arr[arr.length -1] == "5") || (arr[arr.length -1] == "6"))
                {
                    if(mycontrol[i].className != "")
                    {
                        if(!isDate( mycontrol[i].className,"yyyy-MM-dd" ))
                        {
                            alert("请输入时间类型！");
                            mycontrol[i].select();
                            mycontrol[i].focus();
                            return;
                        }
                        fg = (arr[arr.length -2].indexOf("S")?"=>":"=<");
                        tstr += arr[arr.length -2] + fg + mycontrol[i].className + ";";
                        
                    }
                }
                
                 $("Txt_temp").value += mycontrol[i].className + ";";//////////////////////////                   
            }
        }
        if(tstr != "")
        {
            $("Txt_mysql").value = tstr.substring(0,tstr.length-1);
        }
        form1.SearchButton.click();
    }
   
function  CheckQueryData()
{
    document.getElementById("Txt_mysql").value="";
    strSql ="";
    sControls=document.getElementById("txtQueryCls").value;
    arrCls = sControls.split(';');
    for(var i =0;i<arrCls.length-1;i++)
    {
       arr = arrCls[i].split('-');
       if((arr[2] == "1")||(arr[2] == "0"))
        {
            mycontrol = document.getElementById(arrCls[i]);
            if(mycontrol.value != "")
            {
                if(!isNumberOr_Comma( mycontrol.value))
                {
                    alert("请输入整数类型！");
                    mycontrol.select();
                    mycontrol.focus();
                    event.returnValue = false;
                    return;
                }
                strSql += arr[1] + "=" + mycontrol.value + ";";
            }
        }
        else if(arr[2] == "2")
        {
            mycontrol = document.getElementById(arrCls[i]);
            if(mycontrol.value != "")
            {
                if(isLetter( mycontrol.value ))
                {
                    alert("请输入浮点数类型！");
                    mycontrol.select();
                    mycontrol.focus();
                    event.returnValue = false;
                    return;
                }
                strSql += arr[1] + "=" + mycontrol.value + ";";
            }
        }
        else if(arr[2] == "3")
        {
            mycontrol = document.getElementById(arrCls[i]);
            if(mycontrol.value != "")
            {
                strSql += arr[1] + "='" + mycontrol.value + "';";
            }
        }
        else if((arr[2] == "5") || (arr[2] == "6"))
        {
            mycontrol = document.getElementById("S_"+arrCls[i]);
            if(mycontrol.value != "")
            {
                if(!isDate( mycontrol.value,"yyyy-MM-dd" ))
                {
                    alert("请输入时间类型！");
                    mycontrol.select();
                    mycontrol.focus();
                    event.returnValue = false;
                    return;
                }
                fg = (arr[1].indexOf("S")?"=>":"=<");
                strSql += arr[1] + fg + mycontrol.value + ";";
            }
            mycontrol = document.getElementById("E_"+arrCls[i]);
            if(mycontrol.value != "")
            {
                if(!isDate( mycontrol.value,"yyyy-MM-dd" ))
                {
                    alert("请输入时间类型！");
                    mycontrol.select();
                    mycontrol.focus();
                    event.returnValue = false;
                    return;
                }
                fg = (arr[1].indexOf("S")?"=>":"=<");
                strSql += arr[1] + fg + mycontrol.value + ";";
            }
        } 
        else 
        {
            mycontrol = document.getElementById(arrCls[i]);
            if(mycontrol.value != "")
            {
                strSql += arr[1] + "='" + mycontrol.value + "';";
            }
        }    
    }
    //alert(strSql);
    document.getElementById("Txt_mysql").value = strSql; 
}     
 
 //将上次查询条件填入
 function FillControl()
 {
    var temp = document.getElementById("txtQueryData").value;
    if (temp.length==0)
        return;
    
    var arr = temp.split(';');
    var arrLen = arr.length-1;
    for(var i =0;i<arrLen;i++)
    {
        arrData = arr[i].split('=');
        if (arrData[0]!="")
        {
            var tempObj = document.getElementById(arrData[0]);
            if(tempObj == null || typeof(tempObj)=="undefined")
                continue;
            tempObj.value= arrData[1];
            //联动下拉框(10,9的值类型表示下拉）
            if(arrData[0].indexOf("-10")>0 || arrData[0].indexOf("-9")>0)
            { 
                SysDynamicOptions(tempObj);
            }
            
            //特别注意，下面的代码用于弹出框的查询（显示的查询条件） +１
            if(arrData[0].indexOf("-12")>0)
            {
                tempObj = document.getElementById(arrData[0]+"1");
                if(tempObj == null || typeof(tempObj)=="undefined")
                    continue;
                tempObj.value = arrData[1];
            }
        }
    }
 }
 
 function SaveControlData(temp)
 {
    //temp = "";
    //temp = document.getElementById("txtQueryData").value;  
    if (temp.length>0)
    {
        arr = temp.split(';');
        for(var i =0;i<arr.length;i++)
        {
            arrData = arr[i].split('=');
            if ((arrData[1]!=""))
            {
                document.getElementById(arrData[0]).value= arrData[1];
            }
        }
    }
 }
 //robin ............用户端清除查询语句
 function ClearData()
 {
    temp = "";
    temp = document.getElementById("txtQueryCls").value;
    if (temp.length>0)
    {
        arr = temp.split(';');
        for(var i =0;i<arr.length-1;i++)
        {
            if (arr[i]!="")
            {
              document.getElementById(arr[i]).value="";
              
              //下面这一段是清空外键关联（弹出式页面）时，显示的内容
              arr2 = arr[i].split("-");
              if(arr2[2] == "12")
                document.getElementById(arr[i] + "1").value = "";
            }
        }
    }
 }


 //robin 隐藏html按钮(清空按钮)
 function IsHideBtn(key) {
     if (key == 0) {
         document.getElementById("BtnClear").style.display = "none";
     }
     else {
         document.getElementById("BtnClear").style.display = "inline";
     }

 }
 
 //robin.......
 function Link( str )
 {
    window.location.href="GeneralPage_Details.aspx?tablecode="+str;
 }
 
 function AppLink( str )
 {
    window.location.href="../../Public/GeneralPage_Details.aspx?tablecode="+str;
 }
 
 function LinkComOtherTable( str )
 {
    //window.location.href="CommonPage.aspx?table="+str;
    //由于外层html不能用单引号，所以用#来代替，这里需要把#换回单引号。
    var newstr = str.toString();
    var reg = new RegExp("ψ","g");
    var regstr = newstr.replace(reg,"'");
    window.location.href="CommonPage.aspx?table="+regstr;
       
    //window.location.href="CommonPage.aspx?table=tab_hotel&initWhere=hotelname in('adf')";
 }
 
 function LinkCom( str )
 {
    window.location.href="CommonPageDetails.aspx?tablecode="+str;
 }
 
 function AppLinkCom( str )
 {
    window.location.href="~/Public/CommonPageDetails.aspx?tablecode="+str;
 }
 
 //
 function JumpToPage(str)
 {
    window.location.href = str;
 }

 //文心借用
 //robin.......
 function LinkSysParam(ID) {
     window.location.href = "SysParamManager_Details.aspx?SysParametersID="+ID;
 }
 
 
 function openSysFunctionByColumnName(relationStr,o)
 {
        var result = window.showModalDialog("GetRelationRecord.aspx?relationStr="+relationStr,"","dialogHeight:550px; dialogWidth:450px; toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no,help = no, status=no, toolbar=no");
        if(result != undefined)
        {
            if(result=="No")
            {
                document.getElementsByName(o.id)[0].value = "";
                document.getElementsByName(o.id)[0].className = "";
            }
            else 
            {
                result = (result==""?"":(result.substring(0,result.length-1)));
                arr = result.split(';');
                document.getElementsByName(o.id)[0].value = "";
                str_show = "";
                str_value = "";
                for(i=0;i<arr.length;i++)
                {
                    str_show += arr[i].split('_')[1] + ",";
                    str_value +=arr[i].split('_')[0] + ",";
                }
                str_show = str_show.substring(0,str_show.length-1);
                str_value = str_value.substring(0,str_value.length-1);
                document.getElementsByName(o.id)[0].value = str_show;
                document.getElementsByName(o.id)[0].className = str_value;
            }
        }
 }
 
 function openDetails(urlcdtion)
 {
        var result = window.showModalDialog("GeneralPage_Details.aspx?"+urlcdtion,"","dialogHeight:550px; dialogWidth:450px; toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no,help = no, status=no, toolbar=no");
        if(result != undefined)
        {
            if(result=="No")
            {
//                document.getElementsByName(o.id)[0].value = "";
//                document.getElementsByName(o.id)[0].className = "";
            }
            else 
            {
//                result = (result==""?"":(result.substring(0,result.length-1)));
//                arr = result.split(';');
//                document.getElementsByName(o.id)[0].value = "";
//                str_show = "";
//                str_value = "";
//                for(i=0;i<arr.length;i++)
//                {
//                    str_show += arr[i].split('_')[1] + ",";
//                    str_value +=arr[i].split('_')[0] + ",";
//                }
//                str_show = str_show.substring(0,str_show.length-1);
//                str_value = str_value.substring(0,str_value.length-1);
//                document.getElementsByName(o.id)[0].value = str_show;
//                document.getElementsByName(o.id)[0].className = str_value;
            }
        }
 }
 
 function delDataMode()
 {
    var obj = document.getElementsByName("chk_item");
    var sltNotNull = false;
    for(i=0;i<obj.length;i++)
    {
        if(obj[i].checked)
        {
            sltNotNull = true;
            break;
        }
    }
    if(!sltNotNull)
    {
        alert("请选择要删除的选项！");
        return false;
    }
    else
        return delDataByKeys();
 }
 
 function checkDel()
 {
    var obj = document.getElementsByName("chk_item");
    for(i=0;i<obj.length;i++)
    {
        if(obj[i].checked)
        {
            return confirm("是否确认删除？");
        }
    }
    alert("请选择要删除的选项！");
    return false;
 }
 
 
 function delDataByKeys()
 {
    if(confirm("确定要删除吗？"))
    {
        $("DelButton").click();
        return true;
    }
    return false;
}

function delDataMoudle() {
    if (!confirm("确定删除吗？")) {
//        history.back();
        event.returnValue = false; //停止事件的执行,也就是不让继续执行了事件了（只剩后台事件了）
    }
}

function UpdateData(str) {
    var arr = str.split('|');
    //$("RemarkText").readOnly = false;
    //document.getElementById("RemarkText").readOnly = true;
    $("RemarkID").value = arr[1];
    $("RemarkText").value = arr[0];
    $("Creator").value = arr[2];
    $("Createdt").value = arr[3];
    $("TypeButton").click();
   
}    

 
 function SortCol(colName)
 {     
    $("SortTxt").value = colName;
    $("SortButton").click();
 }
 
 
 function SelectCity()
 {
    document.getElementById("selectCity").value = parent.parent.document.getElementById("txSelectCityCode").value;
 }
 
function SelectTheSecond(obj,clsSecond,lsfather) { //
lsfathername = document.getElementById("Child"+clsSecond).value;
var arrValue = lsfather.split(';');
var arrName = lsfathername.split(';');
for(i=0;i<arrValue.length;i++)
{
    var values = arrValue[i].split('-');
    if (obj.value == values[0])
    {
        var labels =arrName[i].split('-'); 
        break;
    }
}
// 清空市列表选择框的内容 
document.getElementById(clsSecond).options.length = 0; 

// 从数组中添加内容 

for(var i = 0; i < values.length - 1; i++) { 

document.getElementById(clsSecond).add(document.createElement("OPTION")); 

document.getElementById(clsSecond).options[i].text=labels[i+1]; //values[i+1]+" "+

document.getElementById(clsSecond).options[i].value=values[i+1]; 

} 

// 选择第一个选项 
document.getElementById(clsSecond).selectedIndex = 0; 

} 


function ClickSelAll(){
    form1.btnSelAll.click();
}
 
 
function DisSpecRole(){
    var specCls = document.getElementById('txSpecRole');
    specCls.style.display = "";
}

function SelSpecRole(obj,clsid){
   var specCls = document.getElementById(clsid);
   //specCls.value ="";
   if (obj.value == "-1")
   {
        specCls.style.display = "";//显示控件
   }
   else
        specCls.style.display = "none";//隐藏控件
        
}
 
 
 
 function KeyClick(ClsId)
{
    if(event.keyCode==13)
    {
        document.getElementById(ClsId).click();
    }
}


function onOpenPopClick(str)
{   
// window.showModalDialog("PopSelect.aspx","请选择", "width= 500,height=600,top=50,left=300,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,titlebar=0");
//   
   //所属杆塔要在指定的线路里面的杆塔取，所以，需要传一个所属线路的id，用于弹出框的过滤条件（where）
   if(str.indexOf("V_TOWER_WIRE")>=0)
   {
       var belongline = document.getElementById("ClsBelongLine").value;  
       if(belongline != null)      
           str = str+"%7c"+belongline;   //%7c表示|   因为这个是经过urlencode的 ，这个值放在最后面  
   }
   window.open("PopSelect.aspx"+"?info="+str,"请选择", "width= 500,height=600,top=50,left=300,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,titlebar=0");
  
}


//定位光标位置，并插入数据

var start=0; 
var end=0; 
function addSelectValue(obj,txInsertId)
{ 
    var textBox = document.getElementById(txInsertId); 
    var pre = textBox.value.substr(0, start); 
    var post = textBox.value.substr(end); 
    var strValue = obj.options[obj.selectedIndex].value;
    var iPos = strValue.indexOf(":");
    strValue = strValue.substr(iPos+1,strValue.length);
    textBox.value = pre +"'"+ strValue+"'" + post; 
} 

function savePos(textBox)
{ 
    //如果是Firefox(1.5)的话，方法很简单 
    if(typeof(textBox.selectionStart) == "number")
    { 
        start = textBox.selectionStart; 
        end = textBox.selectionEnd; 
    } 
//下面是IE(6.0)的方法，麻烦得很，还要计算上'\n' 
    else if(document.selection)
    { 
        var range = document.selection.createRange(); 
        if(range.parentElement().id == textBox.id)
        { 
            // create a selection of the whole textarea 
            var range_all = document.body.createTextRange(); 
            range_all.moveToElementText(textBox); 
            //两个range，一个是已经选择的text(range)，一个是整个textarea(range_all) 
            //range_all.compareEndPoints()比较两个端点，如果range_all比range更往左(further to the left)，则 //返回小于0的值，则range_all往右移一点，直到两个range的start相同。 
            // calculate selection start point by moving beginning of range_all to beginning of range 
            for (start=0; range_all.compareEndPoints("StartToStart", range) < 0; start++) 
            range_all.moveStart('character', 1); 
            // get number of line breaks from textarea start to selection start and add them to start 
            // 计算一下\n 
            for (var i = 0; i <= start; i ++){ 
                if (textBox.value.charAt(i) == '\n') 
                start++; 
            } 
            // create a selection of the whole textarea 
            var range_all = document.body.createTextRange(); 
            range_all.moveToElementText(textBox); 
            // calculate selection end point by moving beginning of range_all to end of range 
            for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end ++) 
            range_all.moveStart('character', 1); 
            // get number of line breaks from textarea start to selection end and add them to end 
            for (var i = 0; i <= end; i ++)
            { 
                if (textBox.value.charAt(i) == '\n') 
                end ++; 
            } 
        } 
    } 
    document.getElementById("Selectstart").value = start; 
    document.getElementById("Selectend").value = end; 
} 

//此函数用来根据数据类型过滤操作方法
//其中value值由列名+数据类型
function setopr(srcObj)
{   
    var obj = document.getElementById("lbCustomOpr");
    
    obj.options.length = 0; //移除所有项, 这样就移除所有项？
    //    for(i=0;i <obj.length;i++)     
    //    { //alert(obj.removeChild);
    //       // obj.remove(0);     //移除首项 
    //       obj.removeChild(
    //        
    //    }
    var colvalue = srcObj.value;
    var arr = colvalue.split("-");
    
    var node   =   document.createElement("<option value='='>"); 
    var text   =   document.createTextNode( "等于"); 
    node.appendChild(text); 
    obj.appendChild(node); 

    if(!(arr[1] == 3 || (arr[1] >= 9 && arr[1] <= 12))) //非字符串
    {        
        if(arr[1] != 4) //bool
        {
            node   =   document.createElement("<option value='>'>"); 
            text   =   document.createTextNode( "大于"); 
            node.appendChild(text); 
            obj.appendChild(node); 
            node   =   document.createElement("<option value='<'>"); 
            text   =   document.createTextNode( "小于"); 
            node.appendChild(text); 
            obj.appendChild(node); 
            node   =   document.createElement("<option value='>='>"); 
            text   =   document.createTextNode( "大于等于"); 
            node.appendChild(text); 
            obj.appendChild(node);
            node   =   document.createElement("<option value='<='>"); 
            text   =   document.createTextNode( "小于等于"); 
            node.appendChild(text); 
            obj.appendChild(node); 
        }        
    }
    else //字符串或者外键
    {
        node   =   document.createElement("<option value='like'>"); 
        text   =   document.createTextNode( "模糊匹配"); 
        node.appendChild(text); 
        obj.appendChild(node);
    }
    
    var dpicker = document.getElementById("DPicker");
    
    if(arr[1] == 5 || arr[1] == 6) //日期或者时间
    {
        dpicker.style.display = "block";;        
    }
    else
    { 
        dpicker.style.display = "none";       
    }
    
    
//    alert(obj.value);
}

/*下面这个函数暂时不用，用页面上的提交按钮来上传了，这里就不用上传了*/
function upfileclick(obj)
{
    var btn = document.getElementById("btnUpComFile");
    document.getElementById("hidden").value=document.getElementById(obj).value;   
    btn.click();      
}

function clearFile(obj)
{
    document.getElementById(obj + "1").value = "";
    document.getElementById(obj + "2").value = "";
}